﻿using System.Linq;
using SapaFinance.Domain.Model;
using SapaFinance.GenericRepository;

namespace SapaFinance.Domain
{
	/// <summary>
	/// Customer specification using fluent interface.
	/// </summary>
	public interface IBudgetItemSpecification : ISpecification<BudgetItem>
	{
		IBudgetItemSpecification WithName(string name);
	
	}

    /// <summary>
    /// Generic specification based on IQueryable interface.
    /// </summary>
    public class BudgetItemQueryableSpecification
        : QueryableSpecification<BudgetItem>
        , IBudgetItemSpecification
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        public BudgetItemQueryableSpecification(IUnitOfWorkConvertor unitOfWorkConvertor)
            : base(unitOfWorkConvertor)
        {
        }

        /// <summary>
        /// Specifies the name the query will filter entities for.
        /// </summary>
        public IBudgetItemSpecification WithName(string name)
        {
            this.Queryable = this.Queryable.Where(c => c.Name == name);
            return this;
        }


    }
}
